package com.tuanzi.loan.business.constants;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@Component
@Transactional
@PropertySource(value = "classpath:statbigclue.properties")
public class H5StatCode {
    @Autowired
    private Environment env;


    public  List<String> getHfiveCityList(String cityname){
        List<String> list = new ArrayList<String>();
        String[] cityarray = cityname.split(",");
        list=Arrays.asList(cityarray);
        return list;
    }

    public  String cityByType(Integer type){
        List<String> citylist = new ArrayList<>();
        StringBuilder citystr = new StringBuilder();
        switch (type){
            case 1:
                //粤好
//                citylist=getHfiveCityList(env.getProperty("statbig.yuehao"));
                break;
            case 2:
                //小小金融
//                citylist=getHfiveCityList(env.getProperty("statbig.xiaoxiaojinrong"));
                break;
            case 3:
                //房互网
                citylist=getHfiveCityList(env.getProperty("statbig.fanghu_city"));
                break;
            case 4:
                //闪贷借款
//                citylist=getHfiveCityList(env.getProperty("statbig.shandai_city"));
                break;
            case 5:
                //好贷网
                break;
            case 6:
                //助贷网
//                citylist=getHfiveCityList(env.getProperty("statbig.zhudai_city"));
                break;
            case 8:
                //51银行贷款
//                citylist=getHfiveCityList(env.getProperty("statbig.fiveone_city"));
                break;
            case 10:
//                citylist = getHfiveCityList(env.getProperty("statbig.rongshu_city"));
                break;
            default:
                break;
        }
        for (int i = 0; i < citylist.size(); i++) {
            if (citylist.size()-1>i) {
                citystr.append("'" + citylist.get(i) + "',");
            }else{
                citystr.append("'" + citylist.get(i) + "'");
            }

        }
        return citystr.toString();
    }
}
